<template>
  <!--   数据表格卡片     -->
  <el-card style="margin-top: 20px; " shadow="hover">
    <el-table
        :data="PopularGoods"
        height="420"
        style="width: 100%">
      <el-table-column
          prop="goodsname"
          label="热门商品"
          width="250">
      </el-table-column>
      <el-table-column
          prop="goodsprice"
          label="单价 (￥)"
          width="95">
      </el-table-column>
      <el-table-column
          prop="kucun"
          label="库存 (件)">
      </el-table-column>
      <el-table-column
      width="80">
        <template slot-scope="scope">
          <button class="contactButton" @click="gotoBuyGoods(scope.row)"> Go
            <div class="iconButton">
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M16.172 11l-5.364-5.364 1.414-1.414L20 12l-7.778 7.778-1.414-1.414L16.172 13H4v-2z"></path></svg>
            </div>
          </button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>

import Request from "@/Network/axios";

export default {
  name: "HomeTable",
  data(){
    return{
      PopularGoods: []
    }
  },

  methods: {
    gotoBuyGoods(goodsinfo){
      this.$router.push({
        name: 'buyGoods',
        query: {
          data : JSON.stringify(goodsinfo)
        }
      })
    }
  },

  mounted() {
    // 获取热门商品信息
    Request({
      url: '/user/getPopularGoods',
      method: 'get',
    }).then(res => {
      this.PopularGoods = res.data.data
    }).catch(err => {
      console.log(err)
    })
  }
}
</script>

<style scoped>
.contactButton {
  background: #7079f0;
  color: white;
  font-family: inherit;
  padding: 0.45em;
  padding-left: 1.0em;
  font-size: 10px;
  font-weight: 500;
  border-radius: 0.9em;
  border: none;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  box-shadow: inset 0 0 1.6em -0.6em #714da6;
  overflow: hidden;
  position: relative;
  height: 2.8em;
  padding-right: 3em;
}

.iconButton {
  margin-left: 1em;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.2em;
  width: 2.2em;
  border-radius: 0.7em;
  box-shadow: 0.1em 0.1em 0.6em 0.2em #7a8cf3;
  right: 0.3em;
  transition: all 0.3s;
}

.contactButton:hover {
  transform: translate(-0.05em, -0.05em);
  box-shadow: 0.15em 0.15em #5566c2;
}

.contactButton:active {
  transform: translate(0.05em, 0.05em);
  box-shadow: 0.05em 0.05em #5566c2;
}
</style>